﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using ReadingList.Contracts.DataContracts.QueryParameters;
using ReadingList.Contracts.DataContracts.QueryResults;
using ReadingList.Contracts.ServiceContracts;

namespace ReadingList.Tests
{
    [TestClass]
    public class UserTests
    {

        public UserTests() {
            Mock<IUserService> userSerivce = new Mock<IUserService>();

            UserQueryResult fakeResult = new UserQueryResult { FirstName = "John", LastName = "Doe", Username = "jDoe" };

            userSerivce.Setup(ms => ms.FindUserByUsername(new UserQueryParameter { Username = "jDoe" })).Returns(fakeResult);

            MockUserService = userSerivce.Object;

        }

        private readonly IUserService MockUserService;

        [TestMethod]
        public void can_find_user_by_username() {
            // Arrange
            UserQueryParameter qP = new UserQueryParameter { Username = "jDoe" };

            // Act
            var result = MockUserService.FindUserByUsername(qP);

            // Assert
            Assert.IsNotNull(result);
        }
    }
}
